<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>教务系统后台管理</title>
<link rel="stylesheet" href="layui/css/layui.css">
<script type="text/javascript" src="layui/layui.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo">教务平台</div>
			<!-- 头部区域（可配合layui已有的水平导航） -->
			<ul class="layui-nav layui-layout-left">
				<li class="layui-nav-item"><a>教师个人主页</a>
					<dl class="layui-nav-child">
						<dd>
							<a th:href="@{/gotoTeacherPage}">教师个人信息</a>
						</dd>
						<dd>
							<a th:href="@{/gotoModifyTeacherMsg}">修改个人信息</a>
						</dd>
					</dl></li>

				<li class="layui-nav-item"><a>成绩管理</a>
					<dl class="layui-nav-child">
						<dd>
							<a th:href="@{/addStudentScore}">学生成绩录入</a>
						</dd>
						<dd>
							<a th:href="@{/goodsinformation}">查看和修改学生信息</a>
						</dd>
					</dl></li>

				<li class="layui-nav-item"><a>课程管理</a>
					<dl class="layui-nav-child">
						<dd>
							<a th:href="@{/gotoselect_personalinformation}">添加课程信息</a>
						</dd>
						<dd>
							<a th:href="@{/gotoselect_allpeopleinformation}">修改课程信息</a>
						</dd>
					</dl></li>

				<li class="layui-nav-item"><a>考试管理</a>
					<dl class="layui-nav-child">
						<dd>
							<a th:href="@{/addExam}">添加考试信息</a>
						</dd>
						<dd>
							<a th:href="@{/modifyExam}">编辑考试信息</a>
						</dd>
					</dl></li>


			</ul>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item"><a href="javascript:;"> <img
						th:src="${image}" class="layui-nav-img"> [[${name}]]
				</a>
					<dl class="layui-nav-child">
						<dd>
							<a th:href="@{/gotoselect_personalinformation}">基本资料</a>
						</dd>
						<dd>
							<a th:href="@{/gotoperfect}">完善个人资料</a>
						</dd>
						<dd>
							<a th:href="@{/edit_personalinformation}">更改账户密码</a>
						</dd>
					</dl></li>
				<li class="layui-nav-item"><a th:href="@{/hello}">退出</a></li>
			</ul>
		</div>

		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree">
					<li class="layui-nav-item"><a href="javascript:;">教师个人主页</a>
						<dl class="layui-nav-child">
							<dd>
								<a th:href="@{/gotoTeacherPage}">教师个人信息</a>
							</dd>
							<dd>
								<a th:href="@{/gotoModifyTeacherMsg}">修改个人信息</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a href="javascript:;">成绩管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a th:href="@{/modifyAndAddStudentScore}">学生成绩录入与修改</a>
							</dd>
							<dd>
								<a th:href="@{/lookStudentScore}">查看学生成绩</a>
							</dd>
						</dl></li>

					<li class="layui-nav-item"><a href="javascript:;">课程管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a th:href="@{/lookClassMessage}">查看课程信息</a>
							</dd>
							<dd>
								<a th:href="@{/gotoAddClassMessage}">添加课程信息</a>
							</dd>
							<dd>
								<a th:href="@{/gotoModifyClassMessage}">修改课程信息</a>
							</dd>
						</dl></li>

					<li class="layui-nav-item"><a href="javascript:;">考试管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a th:href="@{/gotoAddExam}">添加考试信息</a>
							</dd>
							<dd>
								<a th:href="@{/modifyExam}">编辑考试信息</a>
							</dd>
							<dd>
								<a th:href="@{/lookExam}">查看考试信息</a>
							</dd>
						</dl></li>
				</ul>
			</div>
		</div>

		<!--页面主要内容窗口开始-->
		<div class="layui-body" th:if="${nowPage} eq 'teacherMsgPage'">

			<table class="layui-table" lay-even lay-skin="line" lay-size="lg">
				<colgroup>
					<col width="100">
					<col width="300">
					<col>
				</colgroup>

				<tbody>
					<tr>
						<td>教师编号</td>
						<td th:text="${teacherInfo.teacher_number}"></td>
					</tr>
					<tr>
						<td>所在学院</td>
						<td th:text="${teacherInfo.college_id}"></td>
					</tr>
					<tr>
						<td>教师名</td>
						<td th:text="${teacherInfo.teacher_name}"></td>
					</tr>
					<tr>
						<td>性别</td>
						<td th:text="${teacherInfo.teacher_sex}"></td>
					</tr>
					<tr>
						<td>身份证号</td>
						<td th:text="${teacherInfo.teacher_IDcard}"></td>
					</tr>
					<tr>
						<td>手机号</td>
						<td th:text="${teacherInfo.teacher_phone}"></td>
					</tr>
					<tr>
						<td>电子邮箱</td>
						<td th:text="${teacherInfo.teacher_email}"></td>
					</tr>
					<tr>
						<td>家庭住址</td>
						<td th:text="${teacherInfo.teacher_home}"></td>
					</tr>
				</tbody>
			</table>


		</div>
		<!--页面主要内容窗口结束-->

		<div class="layui-body" th:if="${nowPage} eq 'teacherModifyMsgPage'"
			style="padding-top: 20px;">


			<form class="layui-form" th:action="@{/modifyTeacherInfo}">
				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">教师编号</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_number}"
							name="teacher_number" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<!--选则框start-->
				<div class="layui-form-item">
					<label class="layui-form-label">所在学院</label>
					<div class="layui-input-block">
						<select name="city" lay-verify="required">
							<option th:value="${teacherInfo.college_id}"></option>
							<option value="0">软件工程</option>
							<option value="1">物联网</option>
							<option value="2">计算机科学</option>
						</select>
					</div>
				</div>
				<!--选则框end-->

				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">名字</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_name}"
							name="teacher_name" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_sex}"
							name="teacher_sex" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">身份证号</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_IDcard}"
							name="teacher_IDcard" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">手机号</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_phone}"
							name="teacher_phone" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">电子邮箱</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_email}"
							name="teacher_email" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<!--单行数据start-->
				<div class="layui-form-item">
					<label class="layui-form-label">家庭住址</label>
					<div class="layui-input-block">
						<input type="text" th:value="${teacherInfo.teacher_home}"
							name="teacher_home" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!--单行数据end-->

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						<!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
					</div>
				</div>
			</form>



		</div>
		<!--页面主要内容窗口结束-->

		<!-- 添加学生信息start -->
		<div class="layui-body" th:if="${nowPage} eq 'addStudentScore'"
			style="padding-top: 20px;">

			<table id="score" lay-filter="test" width="400"></table>


		</div>
		<!-- 添加学生信息end -->

		<script type="text/javascript" th:inline="none">
		
		</script>


		<!-- 添加学生信息start -->
		<div class="layui-body" th:if="${nowPage} eq 'lookClassMessage'"
			style="padding-top: 20px;">

			<table class="layui-table">
				<colgroup>
					<col width="150">
					<col width="200">
					<col>
				</colgroup>
				<thead>
					<tr>
						<th>学院</th>
						<th>课程名</th>
						<th>上课时间</th>
					</tr>
				</thead>
				<tbody th:each="course:${courseInfo}">
					<tr>
						<td th:text="${course.college_id}">软件工程</td>
						<td th:text="${course.course_name}">周一上午12节</td>
						<td th:text="${course.course_time}">小芳</td>
					</tr>
				</tbody>
			</table>



		</div>
		<!-- 添加学生信息end -->


		<!-- 添加考试信息start -->
		<div class="layui-body" th:if="${nowPage} eq 'AddExam'"
			style="padding-top: 20px;">


			<form class="layui-form" th:action="@{/addExam}">
				<div class="layui-form-item">
					<label class="layui-form-label">课程ID</label>
					<div class="layui-input-block">
						<input type="text" name="course_id" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">考试名称</label>
					<div class="layui-input-block">
						<input type="text" name="exam_name" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">考试时间</label>
					<div class="layui-input-block">
						<input type="text" name="exam_time" required lay-verify="required"
							placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">考试信息</label>
					<div class="layui-input-block">
						<textarea name="exam_msg" placeholder="请输入内容"
							class="layui-textarea"></textarea>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
					</div>
				</div>
			</form>


		</div>
		<!-- 添加考试信息end -->


		<!-- 添加考试信息start -->
		<div class="layui-body" th:if="${nowPage} eq 'modifyExam'"
			style="padding-top: 20px;">
			<form class="layui-form" th:action="@{/upDateModifyExam}">
				<div class="layui-form-item">
					<label class="layui-form-label">课程ID</label>
					<div class="layui-input-block">
						<input type="text" name="course_id" required lay-verify="required"
							th:value="${exam.course_id}" placeholder="请输入标题"
							autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">考试名称</label>
					<div class="layui-input-block">
						<input type="text" name="exam_name" required lay-verify="required"
							th:value="${exam.exam_name}" placeholder="请输入标题"
							autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">考试时间</label>
					<div class="layui-input-block">
						<input type="text" name="exam_time" required lay-verify="required"
							th:value="${exam.exam_time}" placeholder="请输入标题"
							autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">考试信息</label>
					<div class="layui-input-block">
						<textarea id="exam_msg" name="exam_msg" placeholder="请输入内容"
							class="layui-textarea"></textarea>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
					</div>
				</div>
			</form>
		</div>
		<!-- 添加考试信息end -->



		<!--页面主要内容窗口开始-->
		<div class="layui-body" th:if="${nowPage} eq 'lookExam'">

			<table class="layui-table" lay-even lay-skin="line" lay-size="lg">
				<colgroup>
					<col width="100">
					<col width="300">
					<col>
				</colgroup>

				<tbody>
					<tr>
						<td>课程ID</td>
						<td th:text="${exam.course_id}"></td>
					</tr>
					<tr>
						<td>考试名称</td>
						<td th:text="${exam.exam_name}"></td>
					</tr>
					<tr>
						<td>考试时间</td>
						<td th:text="${exam.exam_time}"></td>
					</tr>
					<tr>
						<td>考试信息</td>
						<td th:text="${exam.exam_msg}"></td>
					</tr>
				</tbody>
			</table>


		</div>
		<!--页面主要内容窗口结束-->



		<!-- 添加课程信息start -->
		<div class="layui-body" th:if="${nowPage} eq 'addClassPage'"
			style="padding-top: 20px;">
			<form class="layui-form" th:action="@{/addClassMessage}">
				<div class="layui-form-item">
					<label class="layui-form-label">课程名</label>
					<div class="layui-input-block">
						<input type="text" name="course_name" required
							lay-verify="required" placeholder="请输入课程名" autocomplete="off"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">课程时间</label>
					<div class="layui-input-block">
						<input type="text" name="course_time" required
							lay-verify="required" placeholder="请输入课程时间" autocomplete="off"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
					</div>
				</div>
			</form>
		</div>
		<!-- 添加课程信息end -->


		<script type="text/javascript" th:inline="javascript">
		var page5 = [[${nowPage}]];
		if(page5 == "lookClassMessage"){
			var flag1 = [[${flag}]];
			if(flag1 != null && flag1 == "addClassSuccessful"){
			alert("添加课程信息成功，正在跳转至课程查看界面");
		}
			
			}
		</script>

		<!-- 修改课程信息数据表格 -->
		<div class="layui-body" th:if="${nowPage} eq 'modifyClassMessage'">
			<table id="classTable" lay-filter="test"></table>
		</div>
		<script type="text/javascript" th:inline="javascript">
			var nowpage3 = [[${nowPage}]];
			if(nowpage3=="modifyClassMessage"){
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#classTable',
						url : 'getClassMessage',
						cols : [ [ {
							field : 'course_id',
							width : 100,
							title : '课程id',
							sort : true
						}, {
							field : 'course_name',
							width : 300,
							title : '课程名'
						}, {
							field : 'course_time',
							width : 300,
							title : '课程时间',
						}, {
							fixed: 'right', 
						    width: 300, 
						    align:'center',
						    title:'操作',
						    toolbar: '#bar'}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});

			}
		</script>

		<script type="text/html" id="bar">
 			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">修改</a>
  			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="del">删除</a>
		</script>

		<script type="text/javascript">
			layui.use('table', function(){
			  var table = layui.table;
			  //监听工具条
			  table.on('tool(test)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'detail'){
			    	 var index = layer.prompt({
			        	 formType: 0,
			        	  value: data.course_name,
			        	  closeBtn:0,
			        	  title: '请输入值'
			        	  }, 
			        	function(value, index, elem){
			        	  var a = document.getElementById("zxr").value;
			        	  layer.close(index);
			        	  $.ajax({
								url : 'modifyCourse',
								dataType : 'json',
								async : false,
								type : 'post',
								data : {
									"course_id":data.course_id,
									"course_name": value,
									"course_time":a
								},
								success : function(data) {
									if(data==1){
										alert("修改成功，请刷新页面查看")
										
									}else{
										alert("修改失败")
									}
								}
							})
			        	 })
			        	$(".layui-layer-content").append("<br/><input type=\"text\" id= \"zxr\" class=\"layui-input\" placeholder=\"课程时间\"/>"); 
			      }else if(obj.event === 'del'){
			      layer.confirm('真的删除行么', function(index){
			        obj.del();
			        $.ajax({
						url : 'deleteCourse',
						dataType : 'json',
						type : 'post',
						data : {
							"course_id" : JSON.stringify(data.course_id)
						},
					})
			        layer.close(index);
			      });
			    }else if(obj.event === 'modifyy'){
			    	 var index = layer.prompt({
			        	 formType: 0,
			        	  value: data.score,
			        	  closeBtn:0,
			        	  title: '请输入值'
			        	  }, 
			        	function(value, index, elem){
			        	  layer.close(index);
			        	  $.ajax({
								url : 'modifyScore',
								dataType : 'json',
								async : false,
								type : 'post',
								data : {
									"student_id":data.student_id,
									"score": value,
								},
								success : function(data) {
									if(data==1){
										alert("修改成功，请刷新页面查看")
										
									}else{
										alert("修改失败")
									}
								}
							})
			        	 })
			  
			    }else if(obj.event === 'dell'){
			    	 layer.confirm('真的删除行么', function(index){
					        obj.del();
					        $.ajax({
								url : 'deleteScore',
								dataType : 'json',
								type : 'post',
								data : {
									"course_id" : JSON.stringify(data.course_id)
								},
							})
					        layer.close(index);
					      });
			    }
			  });
			  
			});
		</script>
		
		<div class="layui-body" th:if="${nowPage} eq 'modifyAndAddStudentScore'"
			style="padding-top: 20px;">
			<table id="studentScore1" lay-filter="test"></table>
		</div>
		
		
		
		<script type="text/javascript" th:inline="javascript">
			var nowpage5 = [[${nowPage}]];
			if(nowpage5=="modifyAndAddStudentScore"){
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#studentScore1',
						url : 'getStudentScoreMessage2',
						cols : [ [ {
							field : 'college_id',
							width : 100,
							title : '学院id',
							sort : true
						}, {
							field : 'college_name',
							width : 300,
							title : '学院名'
						}, {
							field : 'score',
							width : 300,
							title : '课程成绩',
						}, {
							field : 'student_id',
							width : 300,
							title : '学生id',
						},{
							field : 'student_name',
							width : 300,
							title : '学生姓名',
						},{
							fixed: 'right', 
						    width: 300, 
						    align:'center',
						    title:'操作',
						    toolbar: '#barr'}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});

			}
		</script>
		
		<script type="text/html" id="barr">
 			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="modifyy">修改</a>
  			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="dell">删除</a>
		</script>
		
		
		
		
		<div class="layui-body" th:if="${nowPage} eq 'lookStudentScore'"
			style="padding-top: 20px;">
			<table id="studentScore2" lay-filter="test"></table>
		</div>
		
		<script type="text/javascript" th:inline="javascript">
			var nowpage5 = [[${nowPage}]];
			if(nowpage5=="lookStudentScore"){
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#studentScore2',
						url : 'getStudentScoreMessage2',
						cols : [ [ {
							field : 'college_id',
							width : 100,
							title : '学院id',
							sort : true
						}, {
							field : 'college_name',
							width : 300,
							title : '学院名'
						}, {
							field : 'score',
							width : 300,
							title : '课程时间',
						}, {
							field : 'student_id',
							width : 300,
							title : '学生id',
						},{
							field : 'student_name',
							width : 300,
							title : '学生姓名',
						}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});

			}
		</script>

		



		<div class="layui-footer">底部固定区域</div>
	</div>

	<script th:inline="javascript">
			var nowpage1 = [[${nowPage}]];
			if(nowpage1=="modifyExam"){
				var msg=[[${exam.exam_msg}]];
				document.getElementById("exam_msg").value=msg;
			}
			var flag = [[${flag}]];
			if(flag!=null && flag=="hadExam"){
				alert("教师同时只能拥有一个考试");
			}
			if(flag!=null && flag=="addExamsuccessful"){
				alert("考试添加成功");
			}
			
			if(flag!=null && flag=="noExam"){
				alert("没有发布的考试信息");
			}
			
			if(flag!=null && flag=="modifyExamSuccessful"){
				alert("修改考试信息成功，正在跳转至考试信息页面");
			}
			
			if(flag!=null && flag=="modifyTeacherMsgSuccessful"){
				alert("修改个人信息成功，正在跳转至个人信息页面");
			}
		 
		</script>

</body>

</html>